package cz.boxdesign.library.entity.dao.query;


public enum OddeleniSqlQuery implements Query {
  UNKNOWN("",0),
  
  SELECT("select * from oddeleni where 1=1 ",Query.SELECT),
  UPDATE("update oddeleni set name = ?, pocet_knih = ? where id = ?",Query.UPDATE),
  INSERT("insert into oddeleni(name,pocet_knih,id) values(?,?,oddeleni_sequence.nextval)",Query.INSERT),
  DELETE("delete from autor where id_a = ?",Query.DELETE);
  
  private String query;
  private Integer value;

  private OddeleniSqlQuery(String query, Integer value) {
    this.query = query;
    this.value = value;
  }

  /* (non-Javadoc)
   * @see cz.boxdesign.library.common.dao.Queries#getQuery()
   */
  @Override
  public String getQuery() {
    return query;
  }

  /* (non-Javadoc)
   * @see cz.boxdesign.library.common.dao.Queries#getValue()
   */
  @Override
  public Integer getValue() {
    return value;
  }
  
  /**
   * @param value the status value
   * @return return status object by value or {@link #UNKNOWN} if not found
   */
  public static OddeleniSqlQuery getByValue(Integer value) {
    for (OddeleniSqlQuery mps : values()) {
      if (mps.getValue().equals(value)) {
        return mps;
      }
    }
    return UNKNOWN;
  }
}
